package com.itbaizhan.service;

import com.itbaizhan.dao.StudentDao;
import com.itbaizhan.domain.Student;

public class StudentService {
    //引入studentDao
    private StudentDao studentDao;

    /*setter注入
    * 1，为属性提供setter方法
    *StudentDao与 StudentService 都 注入容器中， spring容器就会
    * 把studentDao注入到studentService中 给studentService设置属性值
    * 2，配置setter文件*/

    public StudentDao getStudentDao() {
        return studentDao;
    }

    public void setStudentDao(StudentDao studentDao) {
        this.studentDao = studentDao;
    }

    public StudentService() {
    }
/*构造方法注入
    1，有参的构造方法
    2，在bean中配置方件*/

    public StudentService(StudentDao studentDao) {
        this.studentDao = studentDao;
    }

    public Student findById(int id){
       return studentDao.findById(id);
    }
}
